package com.hibernate.relationship.vo;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;

@Entity(name = "Message")
public class Message {

	public Message() {
	}

	public Message(String title) {
		this.messageText = title;
	}

	private Integer id;

	private String messageText;

	private Email email;

	@OneToOne(mappedBy = "message", optional = true)
	public Email getEmail() {
		return email;
	}

	public void setEmail(Email email) {
		this.email = email;
	}

	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getMessageText() {
		return messageText;
	}

	public void setMessageText(String messageText) {
		this.messageText = messageText;
	}

	@Override
	public String toString() {
		return getMessageText();
	}
}
